﻿#region Using

using System;

using Common.Base;

#endregion

namespace GameGraphics.Helper
{
    internal static class TilePositionCalculator
    {
        /// <summary>
        /// Berechnet die Position des Tiles an der angebenen Position
        /// Berechnungen siehe Doc!
        /// </summary>
        /// <param name="x">X Position im Array</param>
        /// <param name="y">Y Position im Array</param>
        /// <param name="startY">Dieser Wert gibt an welche Y Position das BoardTile an der Stelle 0,0 hätte.</param>
        /// <param name="tileSize">Größe des Tiles (aus der Textur)</param>
        /// <returns>Pixel-Position des Tiles</returns>
        public static Position GetPosition(int x, int y, int startY, Size tileSize)
        {
            var posX = (int)Math.Round(tileSize.Width * x * 0.75);
            var posY = startY + (y * tileSize.Height) + ((tileSize.Height / 2) * x);

            var off = (posY / (tileSize.Height / 2)) * 4;
            posY -= off;

            return new Position(posX, posY);
        }
    }
}